package com.autumn.platform.auth.core.access.impl;

import com.autumn.platform.auth.core.access.IAccessController;
import com.autumn.platform.auth.core.access.IPermission;
import com.autumn.platform.core.context.response.IResponse;

public abstract class AbstractAccessController implements IAccessController {

    @Override
    public IResponse isPermitted(IPermission permission) throws Exception {
        if (IPermission.ANY.equals(permission)) {
            AccessControllerContext response = IResponse.success(AccessControllerContext.class);
            response.setPermission(permission);
            response.setLocked(true);
            return response;
        } else {
            return this.doPermitted(permission);
        }
    }

    abstract protected IResponse doPermitted(IPermission permission) throws Exception;

}
